Darstellung der zusammenfassenden Statistik
Humboldt-Universität zu Berlin
2023-12-18
Today we will learn to…
Abbildung 2: Boxplot of df_eng (body mass by age_subject)
1.5*IQR from Q1 (lower whisker) or Q3 (upper whisker)Abbildung 3: Image source: Winter (2019) (all rights reserved)
Abbildung 4: Image source: Wickham et al. (2023) (all rights reserved)
geom_boxplot()geom_boxplot() function from ggplot2 produces boxplots
x or y axis (Abbildung 5)Abbildung 5: A boxplot for all observations of a continuous variable
Abbildung 6: A boxplot for two groups
colour or fill aesthetic.geom_point()
geom_errorbar()
df_eng (body mass by age_subject)mean and sd of rt_lexdec by age_subject?ggplot() with the appropriate aesthetic mapping and geomsgeom_errorbar()
ymin and ymax as its argumentsmean-/+sd, respectivelysum_eng |>
ggplot(aes(x = age_subject, y = mean, colour = age_subject, shape = age_subject)) +
# geom_point(data = df_eng, alpha = .4, position = position_jitterdodge(.5), aes(x = age_subject, y = rt_lexdec)) +
geom_point(size = 3) +
geom_errorbar(width = .5, aes(ymin=mean-sd, ymax=mean+sd)) +
labs(title = "Mean LDT times (+/-1SD)",
x = "Age group",
y = "Reaction time (ms)",
color = "Age group"
) +
scale_color_colorblind() +
theme_bw() +
theme(
legend.position = "none"
)In this section we learned how to…
fig_boxplot, which is a boxplot of the df_eng data, with:
age_subject plotted on the x axisrt_naming on the y-axisage_subject as colour or fill (choose one, there’s no wrong choice)word_category plotted in two facets using facet_wrap()
theme_ setting you choose (e.g., theme_bw(); for more options see here)rt_naming variable from df_eng.Abbildung 8: Plot to be reproduced
patchwork package, plot your boxplot and your errorbar plots side by side. It should look something like Abbildung 9. Hint: if you want to add the “tag levels” (“A” and “B”) to the plots, you need to add + plot_annotation(tag_level = "A") from patchwork.Abbildung 9: Combined plots with patchwork
Hergestellt mit R version 4.3.0 (2023-04-21) (Already Tomorrow) und RStudioversion 2023.9.0.463 (Desert Sunflower).
R version 4.3.0 (2023-04-21)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.2.1
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] magick_2.7.4 patchwork_1.1.3 ggthemes_4.2.4 janitor_2.2.0
[5] here_1.0.1 lubridate_1.9.2 forcats_1.0.0 stringr_1.5.0
[9] dplyr_1.1.3 purrr_1.0.2 readr_2.1.4 tidyr_1.3.0
[13] tibble_3.2.1 ggplot2_3.4.3 tidyverse_2.0.0
loaded via a namespace (and not attached):
[1] utf8_1.2.3 generics_0.1.3 stringi_1.7.12 hms_1.1.3
[5] digest_0.6.33 magrittr_2.0.3 evaluate_0.21 grid_4.3.0
[9] timechange_0.2.0 fastmap_1.1.1 rprojroot_2.0.3 jsonlite_1.8.7
[13] fansi_1.0.4 scales_1.2.1 cli_3.6.1 crayon_1.5.2
[17] rlang_1.1.1 bit64_4.0.5 munsell_0.5.0 withr_2.5.0
[21] yaml_2.3.7 parallel_4.3.0 tools_4.3.0 tzdb_0.4.0
[25] colorspace_2.1-0 pacman_0.5.1 png_0.1-8 vctrs_0.6.3
[29] R6_2.5.1 lifecycle_1.0.3 snakecase_0.11.0 bit_4.0.5
[33] vroom_1.6.3 pkgconfig_2.0.3 pillar_1.9.0 gtable_0.3.4
[37] glue_1.6.2 Rcpp_1.0.11 xfun_0.39 tidyselect_1.2.0
[41] rstudioapi_0.14 knitr_1.44 farver_2.1.1 htmltools_0.5.5
[45] labeling_0.4.3 rmarkdown_2.22 compiler_4.3.0
Woche 10 - Datenvisualisierung 3